﻿using Microsoft.AspNetCore.Builder.Extensions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Volo.Abp;
using Volo.Abp.Castle;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EventBus;
using Volo.Abp.Modularity;
using WorkFlowCore.Authorization;
using WorkFlowCore.Conditions;
using WorkFlowCore.IRepositories;
using WorkFlowCore.Plugins;
using WorkFlowCore.UserSelectors;
using WorkFlowCore.Workflows;
using WorkFlowCore.WorkTasks;
using static WorkFlowCore.WorkFlowCoreService;

namespace WorkFlowCore
{
    [DependsOn(typeof(AbpEventBusModule))]
    [DependsOn(typeof(AbpCastleCoreModule))]
    [DependsOn(typeof(AbpEntityFrameworkCoreModule))]
    public  class WorkFlowCoreModule:AbpModule
    {
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            base.PreConfigureServices(context);

            Configure<PluginOptions>(op =>
            {
                op.BasePath = AppDomain.CurrentDomain.BaseDirectory;
            });
        }

        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            base.ConfigureServices(context);

            var services = context.Services;
            services.AddScoped<UserSelectorManager>();
            services.AddScoped<ConditionManager>();

            services.AddScoped<Workflow>();
            services.AddScoped<WorkflowVersion>();
            services.AddScoped<WorkflowNode>();
            services.AddScoped<WorkflowLine>();
            services.AddScoped<WorkTask>();
            services.AddScoped<WorkStep>();
            services.AddScoped<WorkflowManager>();



            services.AddScoped(typeof(IWorkflowSession), typeof(EmptySession));


        }


    }
}
